@layout("/common/_container.html",{js:["/assets/modular/system/project/project_internetStore.js"]}){
<style>
    .input {
        border: none;
    }

    .editinput {
        width: 230px;
    }

    .name {
        font-weight: bold;
        color: #0C0C0C;
    }

    .layui-table tbody tr:hover,
    .layui-table thead tr,
    .layui-table-click,
    .layui-table-header,
    .layui-table-hover,
    .layui-table-mend,
    .layui-table-patch, .layui-table-tool,
    .layui-table-total, .layui-table-total tr, .layui-table[lay-even] tr:nth-child(even) {
        background-color: #FFFFFF;
    }

    td {
        white-space: nowrap;
    }
    p{
        color: red;
    }
</style>
<body>
<div class="testdiv" id="table">
    <input hidden id="qb" value="${qb}">
    <table class="layui-table" style="width: 90%;margin-left: 20px" id="tables">
        <tbody>
        <thead>
        <tr id="tr">
            <th class="name">分店名称</th>
            <th class="name">对外门店名称</th>
            <th class="name">详细地址</th>
            <th class="name">点餐电话</th>
            <th class="name">公司归属</th>
            <th class="name">每日营业时间</th>
        </tr>
        </thead>
        <tr>
            <td><input class="input editinput" id="fdName" autocomplete="off"/></td>
            <td><input class="input editinput" id="mdName" autocomplete="off"/></td>
            <td><input class="input editinput" id="address" autocomplete="off"/></td>
            <td><input class="input editinput" id="dcPhone" autocomplete="off"/></td>
            <td><input class="input editinput" id="company" autocomplete="off"/></td>
            <td><input class="input editinput" id="business" autocomplete="off"/></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="layui-inline" style="margin-top: 20px;margin-left: 20px">
    <button class="layui-btn icon-btn" onclick="table2excel()">下载
    </button>
    @if(shiro.hasPermission("/project/wsjdbc")){
    <button id="btnKeep" class="layui-btn icon-btn">保存
    </button>
    @}
    <button id="backupPage" class="layui-btn icon-btn">返回
    </button>
    @if(shiro.hasPermission("/project/wsjd")){
    <button id="audit" class="layui-btn icon-btn">状态
    </button>
    @}
<!--    <button id="add" class="layui-btn icon-btn">测试添加-->
<!--    </button>-->

<!--批注说明-->
<div style="margin-top: 50px">
    <p>注意：<p>①：分店名称：写美团括号内的名字</p>
    </p>
    <br>
    <p><p>②：详细地址的省市区规范写好不可省略，地铺门店写好路口，如果有知名品牌可以标注，无法标注的写好门牌号</p>
    <p>如：xx省xx市xx区xx街道xx广场几楼什么位置标注清楚，示例：万达广场三楼中段，万达广场三楼扶梯右手</p></p>
    <br>
    <p>③：订餐电话：店长电话，离职时当天报给公司美团负责人员修改</p>
    <br>
    <p>④：门店营业时间为22小时营业的，营业时间可填写09:00-07:00；如营业时间为：10:00-次日03:00。则写明为：10:00-次日03:00（营业时间非特殊情况不需要修改）</p>
</div>
</div>
</body>

<script src="https://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="application/javascript">

    // 导出表格
    function table2excel() {
        $("#tables tr td").each(function (index, el) {
            if ($(this).find('input').length) {
                // 存在 input
                $(this).find('input').attr('value', $(this).find('input').val());
            }
        });
        $("#tables").table2excel({
            // 不被导出的表格行的CSS class类
            exclude: ".noExl",
            // 导出的Excel文档的名称
            name: "网上建店",
            // Excel文件的名称
            filename: "网上建店",
            //文件后缀名
            fileext: ".xls",
            //是否排除导出图片
            exclude_img: false,
            //是否排除导出超链接
            exclude_links: false,
            //是否排除导出输入框中的内容
            exclude_inputs: true
        });
    }

    //
    // $('#add').click(function () {
    //     $('.input').val('测试')
    // });

    const id = '${id}';
    const content = '${content}';
    const role = '${role}';
    const lists = [${list}];

    $(function () {
        for (let i = 0; i < lists[0][0].length; i++) {
            let pinCode = lists[0][0][i].pinCode;
            $("#" + pinCode + "").val(lists[0][0][i].data);
            if (role != "2") {
                $("#" + pinCode + "").attr("readonly", true);
                $('#btnKeep').hide();
            }
            if (content == "1") {
                $("#" + pinCode + "").attr("readonly", true);
                $('#audit').hide();
                $('#btnKeep').hide();
            }
        }
    });

    $('#btnKeep').click(function () {
        var list = [];
        for (let i = 1; i < 7; i++) {
            var object = {};
            if (i == 1) {
                object.mouldId = "34";
                object.proId = id;
                object.data = $('#fdName').val();
                object.pinCode = "fdName";
            } else if (i == 2) {
                object.data = $('#mdName').val();
                object.pinCode = "mdName";
            } else if (i == 3) {
                object.data = $('#address').val();
                object.pinCode = "address";
            } else if (i == 4) {
                object.data = $('#dcPhone').val();
                object.pinCode = "dcPhone";
            } else if (i == 5) {
                object.data = $('#company').val();
                object.pinCode = "company";
            } else if (i == 6) {
                object.data = $('#business').val();
                object.pinCode = "business";
            }
            object.dataType = 1;
            list.push(object);
        }

        $.ajax({
            type: "post",
            url: "/mouldBoardMsg/add",
            data: JSON.stringify(list),
            contentType: 'application/json',
            async: false,
            success: function () {
                list = [];
                layer.msg('保存成功！', {icon: 1},);
                window.location.href = Feng.ctxPath + '/task/steerTask?id=' + id;

            }, error: function () {
                list = [];
            }
        });
    });

    // 审核
    $('#audit').click(function () {
        layer.open({
            area: ['300px', '150px'],
            title: '状态',
            btn: ['完成', '驳回'],
            btnAlign: 'c',
            type: 1,
            content: ' <div style="text-align:center;" id="div">\n' +
                ' <textarea type="text" hidden class="input" id="reason" placeholder="请填写驳回理由" style="height: 100px;width: 92%;margin-top: 10px;padding-left: 5px;"></textarea>\n' +
                ' </div>',
            yes: function (index, layero) {
                shenHe("1", "网上建店已完成");
            },
            btn2: function (index, layero,) {
                $('.input').show();
                var reason = $('#reason').val();
                if (reason == '') {
                    $('.layui-layer-btn .layui-layer-btn0').hide();
                    $('.layui-layer-btn1').text('提交');
                    $('.layui-layer-btn1').css('background', '#1E9FFF');
                    $('.layui-layer-btn1').css('color', '#FFF');
                    layer.msg('请填写驳回理由！', {icon: 2},);
                    return false;
                } else {
                    shenHe("0", reason);
                    layer.close(index);
                }
            },
        })
    });

    function shenHe(data, reason) {
        let obj = {};
        obj.proId = id;
        obj.status = data;
        obj.taskId = "36";
        obj.content = reason;
        obj.taskName = "网上建店";
        $.ajax({
            type: "post",
            url: "/task/audit",
            data: obj,
            async: false,
            success: function () {
                if (data == 1) {
                    layer.msg('已确认！');
                } else {
                    layer.msg('已驳回！');
                }
                parent.location.reload();
            }
        });
    }
</script>
@}

